import { reactive } from "vue";
import store from "@/store/state/userState"
import { getAddressCode, getAddressText } from "@/hook/hook"
// 用户基本信息
interface UserBasicInfo {
  name: string,
  gander: string,
  birth: string,
  birthAddress: Array<string>,
  newAddress: Array<string>,
  // 政治面貌
  politicalOutlook: string,
  phone: string,
  email: string,
}


export const userBasicInfo = reactive<UserBasicInfo>({
  // 可初始化数据，但和vuex仓库中的数据无关
  name: "",
  gander: "",
  birth: "",
  // birthAddress: getAddressCode(store.state.userBasicInfo.birthAddress),
  // newAddress:  getAddressCode(store.state.userBasicInfo.newAddress),
  birthAddress:["",""],
  newAddress:  ["",""],
  // 政治面貌
  politicalOutlook: "",
  phone: "",
  email:"",
});
// 校验用户基本信息的规则
interface UserInfoRules {
  name: ({
    message: string;
    required: boolean;
    trigger: string;
    min?: undefined;
    max?: undefined;
  } | {
    min: number;
    max: number;
    message: string;
    trigger: string;
    required?: undefined;
  })[];
  gander: {
    message: string;
    required: boolean;
    trigger: string;
  }[];
  birth: {
    type: string;
    required: boolean;
    message: string;
    trigger: string;
  }[];
  birthAddress: {
    required: boolean;
    message: string;
    trigger: string;
  }[];
  newAddress: {
    required: boolean;
    message: string;
    trigger: string;
  }[];
  politicalOutlook: {
    required: boolean;
    message: string;
    trigger: string;
  }[];
  phone: ({
    required: boolean;
    message: string;
    trigger: string;
    pattern?: undefined;
  } | {
    pattern: RegExp;
    message: string;
    trigger: string;
    required?: undefined;
  })[];
  email: {
    type: string;
    message: string;
    required: boolean;
    trigger: string;
  }[];
}

export const userInfoRules = reactive<UserInfoRules>({

  name: [
    {
      message: "用户名不能为空",
      required: true,
      trigger: "blur",
    },
    {
      min: 2,
      max: 30,
      message: "长度在2到30个字符",
      trigger: "blur",
    },
  ],
  gander: [
    {
      message: "请选择你的性别",
      required: true,
      trigger: "change",
    },
  ],

  birth: [
    {
      type: 'date',
      required: true,
      message: '请选择时间',
      trigger: 'change',
    },
  ],
  birthAddress: [
    {
      required: true,
      message: '请选择你的户籍地',
      trigger: 'change',
    },
  ],
  newAddress: [
    {
      required: true,
      message: '请选择你的现居地',
      trigger: 'change',
    },
  ],


  politicalOutlook: [
    {
      required: true,
      message: '请选择你的政治面貌',
      trigger: 'change',
    },
  ],


  phone: [
    { required: true, message: "请输入手机号", trigger: "blur" },
    // 这个只能验证手机号
    // { pattern:/^0{0,1}(13[0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/, message: "请输入合法手机号", trigger: "blur" }
    { pattern: /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/, message: "请输入合法手机号/电话号", trigger: "blur" }
  ],

  email: [
    {
      type: "email",
      message: "请正确输入邮箱",
      required: true,
      trigger: "blur",
    },
  ],


});


// 用户求职状态
interface UserJobStatus{
  userJobState:string
}

export const userJobStatus=reactive<UserJobStatus>({
  userJobState:"",
})
// 校验用户求职状态
interface UserJobStatusRules{
  userJobState: {
    message: string;
    required: boolean;
    trigger: string;
}[];
}

export const userJobStatusRules=reactive<UserJobStatusRules>({
  userJobState: [
    {
      message: "请选择你的求职状态",
      required: true,
      trigger: "change",
    },
  ],
})


// 用户求职意向

interface UserJobIdens{
  title: string,
  salaryMax: string,
  salaryMin: string,
  city: Array<string>,
  jobNature: string,
  industry: Array<string>,
}

export const userJobIdens=reactive<UserJobIdens>({
  title: "Pyt7777hon",

  salaryMax: "3000",
  salaryMin:"6000",
  city: ["",""],
  jobNature: "全职",
  industry: ["",""],
})

// 校验用户求职意向
interface UserJobIdenRules{
  title: {
    message: string;
    required: boolean;
    trigger: string;
}[];
// salaryMax: {
//     message: string;
//     required: boolean;
//     trigger: string;
// }[];
// salaryMin: {
//     message: string;
//     required: boolean;
//     trigger: string;
// }[];
// salary: {
//     message: string;
//     required: boolean;
//     trigger: string;
// }[];
city: {
    message: string;
    required: boolean;
    trigger: string;
}[];
jobNature: {
  message: string;
  required: boolean;
  trigger: string;
}[];
industry: {
  message: string;
  required: boolean;
  trigger: string;
}[];
}

export const userJobIdenRules=reactive<UserJobIdenRules>({
  title:[
    {
      message: "此处不能为空",
      required: true,
      trigger: "blur",
    },
  ],
  // salaryMax:[
  //   {
  //     message: "请选择最高薪资",
  //     required: true,
  //     trigger: "change",
  //   },
  // ],
  // salaryMin:[
  //   {
  //     message: "请选择最低薪资",
  //     required: true,
  //     trigger: "change",
  //   },
  // ],
  // salary:[
  //   {
  //     message: "请选择你期望薪资区间",
  //     required: true,
  //     trigger: "change",
  //   },
  // ],
  city:[
    {
      message: "请选择你期望城市",
      required: true,
      trigger: "change",
    },
  ],
  jobNature:[
    {
      message: "请选择你的工作性质",
      required: true,
      trigger: "change",
    },
  ],
  industry:[
    {
      message: "此处不能为空",
      required: true,
      trigger: "blur",
    },
  ],
})

// 用户教育经历
interface UserEdus{
  schoolName:string
  education:string
  major:string
  schoolTime:Array<string>
  eduMajorDetail:string
}

export const userEdus=reactive<UserEdus>({
  schoolName:"",
  education:"",
  major:"",
  schoolTime:["",""],
  eduMajorDetail:"",
})


// 校验用户教育经历
interface UserEdusRules{
  schoolName: {
        message: string;
        required: boolean;
        trigger: string;
    }[];
    education: {
        message: string;
        required: boolean;
        trigger: string;
    }[];
    major: {
        message: string;
        required: boolean;
        trigger: string;
    }[];
    schoolTime: {
      message: string;
      required: boolean;
      trigger: string;
  }[];
}

export const userEduExsRules=reactive<UserEdusRules>({
  schoolName:[
    {
      message: "此处不能为空",
      required: true,
      trigger: "blur",
    },
  ],
  education:[
    {
      message: "请选择你的工作性质",
      required: true,
      trigger: "change",
    },
  ],
  major:[
    {
      message: "此处不能为空",
      required: true,
      trigger: "blur",
    },
  ],
  schoolTime:[
    {
      message: "此处不能为空",
      required: true,
      trigger: "blur",
    },
  ],
})


// 用户工作经验

interface UserJobEx{
  jobExTime: Array<string>
    jobExEnterprise: string;
    jobExLevel: string;
    jobExDetail: string;

}

export const userJobEx=reactive<UserJobEx>({
  jobExTime:[],
  jobExEnterprise:"",
  jobExLevel:"",
  jobExDetail:"",
})
// 用户项目经验
interface UserProjectEx{
  projectTime: Array<string>
  projectEnterprise: string;
  projectName: string;
  projectDetail: string;
}

export const userProjectEx=reactive<UserProjectEx>({
  projectTime:[],
  projectEnterprise:"",
  projectName:"",
  projectDetail:"",
})


// 用户荣誉奖项
interface UserHonor{
  userHonors: Array<string>
}

export const userHonor=reactive<UserHonor>({
  userHonors:[]
})


// 用户自我评价

interface UserSelfEvaluatio{
  userSelfEvaluation: string;
}

export const userSelfEvaluatio=reactive<UserSelfEvaluatio>({
  userSelfEvaluation:""
})